Skip to content

Conversation

alphashooter
Copy link

No description provided.

bluntcoder and others added 3 commits July 22, 2013 14:50
@alphashooter
Copy link
Author

notifyObservers() method may fail if any Observer to be notified next is removed during the notification loop. E.g. if you register two Mediators for the same notification and the first one removes the second during notification handling, the second Mediator will be notified anyway, and moreover notified after onRemove() method called.
Iterating through a copy of observers_ ref prevents array shifting if you remove any Observer which is already notified (commit 107233d2c23e44a2be96f4fefa4affc74f3afde5); but no checks has been added for the case if you remove any Observer to be notified next. For this case observers_ref holds reference to the source array of Observers; so if any Observer is removed, observers_ref.indexOf(observer) has result -1 and loop continues to the next iteration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants